<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TagM: RTOS::channel&lt; T, SIZE &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">TagM
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="class_r_t_o_s.html">RTOS</a></li><li class="navelem"><a class="el" href="class_r_t_o_s_1_1channel.html">channel</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">RTOS::channel&lt; T, SIZE &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>waitable data queue  
 <a href="class_r_t_o_s_1_1channel.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RTOS::channel&lt; T, SIZE &gt;:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_r_t_o_s_1_1channel.png" usemap="#RTOS::channel&lt; T, SIZE &gt;_map" alt=""/>
  <map id="RTOS::channel&lt; T, SIZE &gt;_map" name="RTOS::channel&lt; T, SIZE &gt;_map">
<area href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class." alt="RTOS::channel_base" shape="rect" coords="0,112,164,136"/>
<area href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for" alt="RTOS::waitable" shape="rect" coords="0,56,164,80"/>
<area href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened" alt="RTOS::event" shape="rect" coords="0,0,164,24"/>
</map>
 </div></div>

<p><a href="class_r_t_o_s_1_1channel-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a5580e7cd248a64985c8866c528cfebe6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1channel.html#a5580e7cd248a64985c8866c528cfebe6">channel</a> (<a class="el" href="class_r_t_o_s_1_1task.html">task</a> *<a class="el" href="class_r_t_o_s_1_1event.html#a1402687edb26c1d5d26e54dbda21919d">t</a>, const char *name=&quot;&quot;)</td></tr>
<tr class="memdesc:a5580e7cd248a64985c8866c528cfebe6"><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor, specify stored type, number of entries, and name  <a href="#a5580e7cd248a64985c8866c528cfebe6"></a><br/></td></tr>
<tr class="memitem:a09e4d10e0336283eb9ae402df0a25dbc"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a09e4d10e0336283eb9ae402df0a25dbc"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1channel.html#a09e4d10e0336283eb9ae402df0a25dbc">write</a> (T item)</td></tr>
<tr class="memdesc:a09e4d10e0336283eb9ae402df0a25dbc"><td class="mdescLeft">&#160;</td><td class="mdescRight">write an item to the queue <br/></td></tr>
<tr class="memitem:a66da852f3e9ef72066e5f582f4c2f218"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a66da852f3e9ef72066e5f582f4c2f218"></a>
T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1channel.html#a66da852f3e9ef72066e5f582f4c2f218">read</a> (void)</td></tr>
<tr class="memdesc:a66da852f3e9ef72066e5f582f4c2f218"><td class="mdescLeft">&#160;</td><td class="mdescRight">read an item from the queue <br/></td></tr>
<tr class="memitem:afd8cd81a91225ed144fc1ca20f3cd8f6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1channel.html#afd8cd81a91225ed144fc1ca20f3cd8f6">clear</a> (void)</td></tr>
<tr class="memdesc:afd8cd81a91225ed144fc1ca20f3cd8f6"><td class="mdescLeft">&#160;</td><td class="mdescRight">clear the waitable  <a href="#afd8cd81a91225ed144fc1ca20f3cd8f6"></a><br/></td></tr>
<tr class="inherit_header pub_methods_class_r_t_o_s_1_1channel__base"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_class_r_t_o_s_1_1channel__base')"><img src="closed.png" alt="-"/>&nbsp;Public Member Functions inherited from <a class="el" href="class_r_t_o_s_1_1channel__base.html">RTOS::channel_base</a></td></tr>
<tr class="memitem:a8aecf8b9c2f96a8bf9b9f42c973a8195 inherit pub_methods_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8aecf8b9c2f96a8bf9b9f42c973a8195"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>print</b> (std::ostream &amp;s, bool header=true) const </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pro_methods_class_r_t_o_s_1_1channel__base"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_class_r_t_o_s_1_1channel__base')"><img src="closed.png" alt="-"/>&nbsp;Protected Member Functions inherited from <a class="el" href="class_r_t_o_s_1_1channel__base.html">RTOS::channel_base</a></td></tr>
<tr class="memitem:ac0624c73bb8e1bf12baf944aaf70ee81 inherit pro_methods_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac0624c73bb8e1bf12baf944aaf70ee81"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>channel_base</b> (<a class="el" href="class_r_t_o_s_1_1task.html">task</a> *<a class="el" href="class_r_t_o_s_1_1event.html#a1402687edb26c1d5d26e54dbda21919d">t</a>, const char *name)</td></tr>
<tr class="inherit_header pro_methods_class_r_t_o_s_1_1waitable"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_class_r_t_o_s_1_1waitable')"><img src="closed.png" alt="-"/>&nbsp;Protected Member Functions inherited from <a class="el" href="class_r_t_o_s_1_1waitable.html">RTOS::waitable</a></td></tr>
<tr class="memitem:a5a5bf9012a332a6451ee10728153908a inherit pro_methods_class_r_t_o_s_1_1waitable"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1waitable.html#a5a5bf9012a332a6451ee10728153908a">waitable</a> (<a class="el" href="class_r_t_o_s_1_1task.html">task</a> *<a class="el" href="class_r_t_o_s_1_1task.html">task</a>, const char *name)</td></tr>
<tr class="memdesc:a5a5bf9012a332a6451ee10728153908a inherit pro_methods_class_r_t_o_s_1_1waitable"><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor, specify owner and name  <a href="#a5a5bf9012a332a6451ee10728153908a"></a><br/></td></tr>
<tr class="memitem:a3a72bdf94092471e82ba2d04cdc4a58e inherit pro_methods_class_r_t_o_s_1_1waitable"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3a72bdf94092471e82ba2d04cdc4a58e"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1waitable.html#a3a72bdf94092471e82ba2d04cdc4a58e">set</a> (void)</td></tr>
<tr class="memdesc:a3a72bdf94092471e82ba2d04cdc4a58e inherit pro_methods_class_r_t_o_s_1_1waitable"><td class="mdescLeft">&#160;</td><td class="mdescRight">set the waitable <br/></td></tr>
<tr class="inherit_header pro_methods_class_r_t_o_s_1_1event"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_class_r_t_o_s_1_1event')"><img src="closed.png" alt="-"/>&nbsp;Protected Member Functions inherited from <a class="el" href="class_r_t_o_s_1_1event.html">RTOS::event</a></td></tr>
<tr class="memitem:a00cf9d5d01e670e2b358c2a4c7578e7d inherit pro_methods_class_r_t_o_s_1_1event"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a00cf9d5d01e670e2b358c2a4c7578e7d"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1event.html#a00cf9d5d01e670e2b358c2a4c7578e7d">event</a> (<a class="el" href="class_r_t_o_s_1_1task.html">task</a> *<a class="el" href="class_r_t_o_s_1_1event.html#a1402687edb26c1d5d26e54dbda21919d">t</a>, unsigned int <a class="el" href="class_r_t_o_s_1_1event.html#a74f6161d8c82d461ae3ba29f0e222b59">mask</a>)</td></tr>
<tr class="memdesc:a00cf9d5d01e670e2b358c2a4c7578e7d inherit pro_methods_class_r_t_o_s_1_1event"><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor, used by concrete events <br/></td></tr>
<tr class="inherit_header pro_attribs_class_r_t_o_s_1_1channel__base"><td colspan="2" onclick="javascript:toggleInherit('pro_attribs_class_r_t_o_s_1_1channel__base')"><img src="closed.png" alt="-"/>&nbsp;Protected Attributes inherited from <a class="el" href="class_r_t_o_s_1_1channel__base.html">RTOS::channel_base</a></td></tr>
<tr class="memitem:a2bb25fb293fd233b6dc3ff32499b28c4 inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2bb25fb293fd233b6dc3ff32499b28c4"></a>
const char *&#160;</td><td class="memItemRight" valign="bottom"><b>channel_name</b></td></tr>
<tr class="memitem:a51b4bf40bab66baad02b1093fb508f9c inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a51b4bf40bab66baad02b1093fb508f9c"></a>
<a class="el" href="class_r_t_o_s_1_1channel__base.html">channel_base</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>next_channel</b></td></tr>
<tr class="memitem:aad82d7f5a2585f45ddca2268f4d35876 inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aad82d7f5a2585f45ddca2268f4d35876"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>writes</b></td></tr>
<tr class="memitem:a573da302e6106eb461d7d50474b1975a inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a573da302e6106eb461d7d50474b1975a"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>ignores</b></td></tr>
<tr class="memitem:a2edc0d4eed9af8e0fccf1288dcb3dafb inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2edc0d4eed9af8e0fccf1288dcb3dafb"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>qSize</b></td></tr>
<tr class="memitem:a46db06f8fcca0241ed2391589db69bae inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a46db06f8fcca0241ed2391589db69bae"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>head</b></td></tr>
<tr class="memitem:ae6aeb780debe979366de36c1da9aabe4 inherit pro_attribs_class_r_t_o_s_1_1channel__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae6aeb780debe979366de36c1da9aabe4"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>tail</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;class T, const int SIZE&gt;<br/>
class RTOS::channel&lt; T, SIZE &gt;</h3>

<p>waitable data queue </p>
<pre class="fragment">  The (communication) channel is a template class that stores a queue 
  of values. 
  Values can be written at the tail of the queue, up to the number of 
  entries for which the channel was created. 
  It is an error to write to a channel that is full. 
  Writes are not blocking. 
  Any task can write to a channel. 

  A channel is created for a particular task. 
  Only this owner task can read from the channel. 
  A read will block until an entry is available. 
  Reads are from the head of the queue.

  A channel is a waitable, so the task that owns the channel 
  can wait for the channel to be non-empty, after which a read 
  from a channel will be non-blocking (because the channel is 
  not empty). 
  After a wait() that returns the channel's event, the channel 
  will set itself again (because the wait did not cause it to 
  become empty). 
  Only a read that results in an empty queue will clear the channel. 

  The example below shows how writing to cout can be buffered 
  by first writing to a 2kB channel, and reading from that 
  channel at a maximum of one character per 2 MS. 
  The UART hardware in the LPC2148 chip buffers one character, 
  which at default baudrate (38k4) takes ~ 1 MS to write. 
  So by writing at a maximum rate of one character per 2 MS 
  no blocking will occur.

  @code 
</pre><p>class output_class : public task { public: channel&lt; char, 2048 &gt; buffer( flags, "buffer" ); timer hartbeat( flags, "hartbeat" ); void main( void ){ for(;;){ wait( buffer ); cout &lt;&lt; buffer.get(); timer.set( 2 MS ); wait( timer ); } } }</p>
<p>output_class output;</p>
<p>void print( char *s ){ while( *s != '\0' ){ output.buffer.write( *s++ ); } }</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a5580e7cd248a64985c8866c528cfebe6"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, const int SIZE&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_r_t_o_s_1_1channel.html">RTOS::channel</a>&lt; T, SIZE &gt;::<a class="el" href="class_r_t_o_s_1_1channel.html">channel</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_r_t_o_s_1_1task.html">task</a> *&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em> = <code>&quot;&quot;</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>constructor, specify stored type, number of entries, and name </p>
<p>The template argument T must be a class that has a non-arguments constructor and supports assignment. </p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="afd8cd81a91225ed144fc1ca20f3cd8f6"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T, const int SIZE&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_r_t_o_s_1_1channel.html">RTOS::channel</a>&lt; T, SIZE &gt;::clear </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>clear the waitable </p>
<p>This is automatically doen when the waitable causes a <a class="el" href="class_r_t_o_s_1_1task.html#a6fc603d0f1c8a94813586d3dfd123fcc" title="wait for all waitables created for this task">task::wait()</a> call to return it. </p>

<p>Reimplemented from <a class="el" href="class_r_t_o_s_1_1waitable.html#a44ac71980592721bc03e076acc7e8c67">RTOS::waitable</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 27 2012 11:07:15 for TagM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
